package kr.hkit.powerjava.chapter06.submit2class;

import java.util.Scanner;

class ForWork01a {

	int suma, ia;

	public ForWork01a(int suma, int ia) {
		this.suma = suma;
		this.ia = ia;
	}

	public int totala() {
		for (int ia = 1; ia <= 100; ia++)
			suma += ia;

		return suma;
	}

	@Override
	public String toString() {
		return "1~100까지 정수들의 합은: " + totala();
	}

}

class ForWork01b {

	Scanner input = new Scanner(System.in);

	int sumb;
	int ib, nb;

	public ForWork01b(int sumb, int ib, int nb) {
		this.sumb = sumb;
		this.ib = ib;
		this.nb = nb;
	}

	public void totalb() {

		System.out.print("정수를 입력하시오: ");
		ib = input.nextInt();

		do {
			System.out.print("정수를 입력하시오: ");
			nb = input.nextInt();

			sumb = sumb + nb;
			ib--;

		} while (ib != 0);
		System.out.println("입력한 정수의 합은 " + sumb + "입니다.");
	}

	/*
	 * @Override public String toString() { return "ForWork02b [totalb()=" +
	 * totalb() + "]"; }
	 */

}

class ForWork01c {

	Scanner input = new Scanner(System.in);

	int sumc;
	int ic;

	public ForWork01c(int sumc, int ic) {
		this.sumc = sumc;
		this.ic = ic;
	}

	public void totalc() {

		do {
			System.out.print("정수를 입력하시오: ");
			ic = input.nextInt();

			if (ic != 0)
				sumc = sumc + ic;
		} while (ic != 0);

		System.out.println("입력한 정수의 합은 " + sumc + "입니다. ");

	}
}

class ForWork02 {

	int n2, nmg;

	public ForWork02(int n2, int nmg) {
		this.n2 = n2;
		this.nmg = nmg;
	}

	public void change() {
		do {
			if (n2 >= 0) {
				nmg = n2 % 10;
				System.out.print(nmg + " ");
				n2 = n2 / 10;
			} else {
				System.out.println("양수를 입력하시오");
				break;
			}
		} while (n2 != 0);
	}
}

class ForWork03 {

	Scanner input = new Scanner(System.in);

	int answer;
	int guess;

	public ForWork03 (int guess, int answer) {
		this.answer = 60;
		this.guess = guess;
	}

	public void guessWhat() {
		do {

			System.out.print("숫자를 입력하시오: ");
			guess = input.nextInt();
			
			if (guess > answer) 
				System.out.println("숫자가 높습니다.");
			if (guess < answer) 
				System.out.println("숫자가 낮습니다.");
			
		} while (guess != answer);
		System.out.println("정답입니다.");
	}
}
